package pkg

import (
	"fmt"
	"github.com/smartwalle/alipay/v3"
)

type Smartwalle interface {
	pay()
}
type AliPay struct {
	Subject     string
	OutTradeNo  string
	TotalAmount string
}

func (a *AliPay) Pay() string {
	var privateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQChM1qib3Xb7DNax0NBJ6jsInBAUDxexlwolU5tEzQxW3DHpQje0RS4f2lWAmVUOMQ11VB+6ISXTh6Agd3jJ0gBLeA6TZqif7hsKGZundmj5cOB88TlaBLBxGx4opv819daEMpJ5fj355UNMM45Urj4QfH33Jn7Ui5qxg50Cv17XtgdA3fbHRqws9/c/jtw8g18npgI8U4lR8iolLQizZxv6MTqMfpcX7M8GbXmekv5RwNpwmzNN4Ra/A4upEHdqHxwjlPSMfOGX3yyjA2TW3OFxJUnPMItcpzG+Vecdleb4JTe/WrTUf0DYVzl+lZ0LwI09+cQYAnz25IT/LeuWJJrAgMBAAECggEAcn0YuBlVqda+OpEfcR0L2nozI1pZJi7XsXMpekqTXSLGnOTXwfjZMJg9ZfrZoNGYeWuBekEGOrge7cJOp1B00XGVuZL4asUvZJHk/ldaBg/fpWJOy2f5OmmZaKyFATUDHFKkeYu+IcP2lqG9NfVMrfWYNyQUsOyTTv5PsZdEpON2+lcy6Z3wiJR0qDpzZjqhJ51PkXw1VzHWDYGu3OgJ9kexdQwfK5lYdPCRj2gyD9Q0blGjqFaZwWDjnL6LAKsfvMNDNuCMUdRSlJpoKm9HLaQZ4YN9AEKjCfXL8k9bz3bzxL/zvvCzPwPHn8qncGbdSO15nGD2/wgNbfbj0TfSwQKBgQD5vUtDHKh2EgHy+zGXX5v0aNQss4PDWh1qpbdwGdaUm4cgC61Yqv/qSF5cDLo7gT6qd6yDpfUSKzjx3TmANT8U2RUTxTSww4Pp5+H9gGUyI6HOY3TQaAwpuaARzdAscMwebmwyh3k6M63aOF29leXF+bhcv+Dfh4S2ufqNqOnWGwKBgQClPdxpJJLhgFdHknv1eVnXX60ev4t9glFgfWHg0BzX5sOcPcHd3+w7I+I19UjGDfs78nWOBQEpSmDX481tPPmtPlYPzfYaspMJuml9Q+Gkzl4XIcdFRcJ6azS+HLrhdvEdAFvvDeHKdTMa/ukEeWeTHAxjT0iZSnnVekIhLT458QKBgCXAkscDZwfqMvc7N8TtRBMPYbucK3f1gGrlwDQnA8QVOrkCauLzfpo49GKv3dsu730veBmylbh4ZjRRv+Z8phuNsVz6u7tY4vESB5ydsy6AKm6bpEX45JXOJL9sQGLnbkPPZ3W/+vhsZYSObsVBCqoB1PfYXbMMtmg09wZBGZAvAoGBAI0C8HANlQa5FkJuwDfoOgHwlPUTcr9FkZptBTTrhGG+fRl9Hk7wg1Cou6deTZ8uWUJ8E1OB886/uUsjDLB3A36THrBYC/gWgiIgIVuTrSCON384BSyZbnA3woemTtiPPw2Hu+ySBShXwaf89u8ph3jjy7KH+yVNiBDkR0C2sk6RAoGAM0EJHj9BeXpzIqwjsW3YPSNlai+U9vXU89AdKkOaJ0D3bf5YjZcS2lrH6EaIL/Be72w8Nk+9KLkT1PE8vSsFFMaiYNJPgLahmfTamJJA00pqTcO7J9jtHqerE10XxMl5/OpwqlzsrUeCgSQx5kkOXYxt76pbjbXfFUXt2yMRq1Y" // 必须，上一步中使用 RSA签名验签工具 生成的私钥
	var appId = "9021000143643559"
	var err error
	client, err := alipay.New(appId, privateKey, false)
	if err != nil {
		fmt.Println(err)
		return ""
	}

	var p = alipay.TradeWapPay{}
	p.NotifyURL = ""
	p.ReturnURL = ""
	p.Subject = a.Subject
	p.OutTradeNo = a.OutTradeNo
	p.TotalAmount = a.TotalAmount
	p.ProductCode = "QUICK_WAP_WAY"

	url, err := client.TradeWapPay(p)
	if err != nil {
		fmt.Println(err)
		return ""
	}

	// 这个 payURL 即是用于打开支付宝支付页面的 URL，可将输出的内容复制，到浏览器中访问该 URL 即可打开支付页面。
	var payURL = url.String()
	fmt.Println(payURL)
	return payURL
}
